﻿using CPF;
using CPF.Animation;
using CPF.Charts;
using CPF.Controls;
using CPF.Drawing;
using CPF.Shapes;
using CPF.Styling;
using CPF.Svg;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Net.Mime.MediaTypeNames;

namespace CPFUI.IControl
{
    [CPF.Design.DesignerLoadStyle("res://$safeprojectname$/Stylesheet1.css")]//用于设计的时候加载样式
    public class MenuGroupItem : Control
    {
        public StackPanel MenuList;
        public MenuGroupItem()
        {
            MenuList = new StackPanel()
            {
                MarginTop = 30,
                MarginLeft = 10,
                MarginRight = 10,
                MarginBottom = 0,
            };

        }
        public string Caption
        {
            get { return GetValue<string>(); }
            set
            {
                SetValue(value);
            }
        }
        //模板定义
        protected override void InitializeComponent()
        {
            Children.Add(new TextBlock
            {
                MarginLeft = 10,
                MarginRight = 10,
                MarginTop=0,
                Height = 30,
                VerticalAlignment = VerticalAlignment.Center,
                Text = "菜单",
                FontSize = 11,
                Foreground = "#000",
                Bindings =
                {
                    {
                        nameof(TextBlock.Text),
                        nameof(Caption),
                        this,
                        BindingMode.TwoWay
                    },
                    {
                        nameof(TextBlock.Foreground),
                        nameof(Foreground),
                        this,
                        BindingMode.TwoWay
                    }
                },
            });
            Children.Add(MenuList);
        }
        public void AddItem(MenuControlItem item)
        {
            MenuList.Children.Add(item);
        }
#if !DesignMode //用户代码写到这里，设计器下不执行，防止设计器出错
        protected override void OnInitialized()
        {
            base.OnInitialized();

        }
        //用户代码

#endif
    }
}
